Skip to content

SES time zone #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 27, 2020
Merged

SES time zone #135

merged 5 commits into from
Jun 27, 2020

Conversation

adam-fowler
Copy link
Member

Support decoding time zones in the following format Fri, 26 Jun 2020 03:04:03 -0500 (CDT)

Motivation:

Currently if an email is received with the common header date which includes the timezone in alphabetical form in brackets after the numeric timezone the date does not decode, and SES.Event does not decode.

Modifications:

Code changes include cropping text after any open bracket found in the date string before passing it through the dateFormatter. I don't know of a dataFormat string that will support the above format. If there is one obviously it would be better to use that instead.

Result:

SES.Event decodes even when it holds a date in the above format

Sometimes common header date comes with an alphabetical timezone in brackets after the numeric timezone
Copy link
Member

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @adam-fowler, I think this is a great addition. Would you mind adding a code comment, where we do the split of?

Comment on lines 84 to 85
let bracket = string.firstIndex(of: "(") ?? string.endIndex
let dateString = String(string[string.startIndex ..< bracket])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would love to see a comment here why we are doing this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we potentially save an allocation by making the string a var and rewriting it only if we find a bracket?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both of them are done

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

orthogonal to these changes but we should add a link to SES event from https://github.com/swift-server/swift-aws-lambda-runtime#integration-with-aws-platform-events

@adam-fowler
Copy link
Member Author

orthogonal to these changes but we should add a link to SES event from https://github.com/swift-server/swift-aws-lambda-runtime#integration-with-aws-platform-events

Added the link in

@tomerd tomerd merged commit 5130278 into swift-server:master Jun 27, 2020
@tomerd
Copy link
Contributor

tomerd commented Jun 27, 2020

thanks @adam-fowler

@adam-fowler adam-fowler deleted the ses-time-zone branch August 7, 2020 07:20
@swift-server swift-server deleted a comment Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants